package com.clkj.mobileinspector.utils;

import android.content.Context;

import com.lws.basic.utils.common.SharePreferenceUtils;

/**
 * @松 on 2020/2/29 19:47
 */
public class UserUtils {
    /**
     * 保存登录用户信息
     * @param user
     * @param context
     */
//    public static void saveUser(User user, Context context){
//        SharePreferenceUtils.putString(context, "app_user", GsonUtils.getInstance().toJson(user));
//
//        SharePreferenceUtils.putBoolean(context, "isLogin", true);
//        SharePreferenceUtils.putString(context,"token",user.getUser().getToken());
//        SharePreferenceUtils.putInt(context,"userId",user.getUser().getUserId());
//        SharePreferenceUtils.putString(context,"name",user.getUser().getName());
//        SharePreferenceUtils.putString(context,"username",user.getUser().getUsername());
//        SharePreferenceUtils.putString(context, "headUrl",user.getUser().getPicUrl());
//
//        SharePreferenceUtils.putInt(context,"lineId",user.getUser().getLineId());
//        SharePreferenceUtils.putInt(context,"specialtyId",user.getUser().getSpecialtyId());
//        SharePreferenceUtils.putString(context,"zoneId",user.getUser().getZoneId());
//
//    }

    /**
     * 清空用户数据

     * @param context
     */
    public static void clearUser( Context context){
        SharePreferenceUtils.putString(context, "app_user", "");

        SharePreferenceUtils.putBoolean(context, "isLogin", false);
        SharePreferenceUtils.putString(context,"token","");
        SharePreferenceUtils.putInt(context,"userId",0);
        SharePreferenceUtils.putString(context,"name","");
        SharePreferenceUtils.putString(context,"username","");
        SharePreferenceUtils.putString(context, "headUrl","");
        SharePreferenceUtils.putInt(context,"lineId",0);
        SharePreferenceUtils.putInt(context,"specialtyId",0);
        SharePreferenceUtils.putString(context,"zoneId","");

    }

    public static String getUserName(Context context){
        return  SharePreferenceUtils.getString(context,"username","");

    }
}
